diff --git a/en/cgi/url.cgi b/en/cgi/url.cgi index cb6e1c5b4f..5526a6553d 100755 --- a/en/cgi/url.cgi +++ b/en/cgi/url.cgi @@ -1,127 +1,142 @@ #!/usr/bin/perl -T # # Copyright (c) Oct 1997-1999 Wolfram Schneider . Berlin. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # url.cgi - make plain text URLs clickable # -# $FreeBSD: www/en/cgi/url.cgi,v 1.30 2001/12/11 21:37:30 wosch Exp $ +# $FreeBSD: www/en/cgi/url.cgi,v 1.31 2002/05/02 14:21:40 wosch Exp $ use strict; $main::hsty_base = '..'; $main::hsty_email = 'ports@FreeBSD.org'; # shutup perl -w my $dummy = $main::hsty_base . $main::hsty_email; undef $dummy; require "./cgi-lib.pl"; require "./cgi-style.pl"; my $file = $ENV{'QUERY_STRING'}; my $uri = "$file"; my $portcategory; # security checks if ($file !~ m%^(http|ftp)://[a-z_\-0-9]+\.freebsd\.(com|org)%i && $file !~ m%^ports/%) { &CgiError(("Invalid url: $file", "Only http://*.freebsd.* is allowed.\n")); exit(0); } # backward compatible with old ports layout $file =~ s%/pkg/DESCR$%/pkg-descr%; # catch '..', multiple times # ports/japanese/ppxp/../../net/ppxp/pkg-descr # -> ports/net/ppxp/pkg-descr 1 while $file =~ s%/[^/]+/\.\./%/%; # print HTML header $file =~ s%(http|ftp)://ftp.freebsd.org/pub/FreeBSD/(branches/|FreeBSD)-current/%%i; if ($file =~ m%^ports/([\w-]+)/(\w[\w-+.]+)/pkg-descr%) { print &html_header( "Port description for $1/$2"); $portcategory = $1; } else { print &short_html_header($file); } -# do cvs checkout +my $isvalidfilename = ($file =~ m%^ports/[\w-]+/\w[\w-+.]*/pkg-descr%); +my $atticfile = $file; +$atticfile =~ s%^(.*)/([^/]+)$%$1/Attic/$2%; + my($cvsroot) = '/usr/local/www/cvsroot/FreeBSD'; -if ($file =~ m%^ports/[\w-]+/\w[\w-+.]*/pkg-descr% && -f "$cvsroot/$file,v") { - open(CO, "-|") || - exec ('/usr/bin/co', '-p', '-q', "$cvsroot/$file,v") || - die "exec co -pq $cvsroot/$file,v: $!\n"; -} +my $realfile; + +# since CVS moves deleted files into the Attic subdirectory we also +# want to look there, so we can find CVS deleted files (which might +# still be referenced from other places). +if ($isvalidfilename && -f "$cvsroot/$file,v") { + $realfile = $file; +} elsif ($isvalidfilename && -f "$cvsroot/$atticfile,v") { + $realfile = $atticfile; +} else { + $isvalidfilename = 0; +} -else { +# do cvs checkout +if($isvalidfilename) { + open(CO, "-|") || + exec ('/usr/bin/co', '-p', '-q', "$cvsroot/$realfile,v") || + die "exec co -pq $cvsroot/$realfile,v: $!\n"; +} else { print "

The port specified does not exist, or has an invalid name:

", "

$file
\n"; # Server environment variables my $http_referer = $ENV{'HTTP_REFERER'}; # rfc1738 says that ";"|"/"|"?"|":"|"@"|"&"|"=" may be reserved. $http_referer =~ s/([^a-zA-Z0-9;\/?:&=])/sprintf("%%%02x",ord($1))/eg; if ($http_referer) { print qq{

You are coming from

$http_referer.

\n}; } print "

Please contact www\@freebsd.org\n"; warn "$0: invalid port name: `$file', $http_referer\n"; } print "\n


\n
\n";
 
 # read the pkg-descr file and make URLs clickable
 my($content);
 $content .= $_ while();
 $content =~ s/])%$1%gi;
 
 print $content;
 print "
\n"; # Add 'source' link for freebsd ports if ($file =~ m%^(ports/[\w-]+/\w[\w-+.]+)/pkg-descr%) { print qq{
Sources |\n}; print qq{}; print qq{Category $portcategory\n}; print qq{| Help\n}; print qq{
\n}; } # print standard footer line print &html_footer; # Sleep 0.35 seconds to avoid DoS attacks from broken robots select undef, undef, undef, 0.35; exit;